package com.example.jpa_h2_querydsl.repository;

import com.example.jpa_h2_querydsl.entity.H2User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface H2UserRepository extends
        JpaRepository<H2User,String>,
        JpaSpecificationExecutor<H2User>,
        QuerydslPredicateExecutor<H2User>,
        CrudRepository<H2User,String> {

    List<H2User> findByUsername(String username);

    @Query("from H2User where username is not null and username=:username")
    List<H2User> findOne(String username);
}
